﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using POS.Framework;

namespace POS.ModForm.Bill
{
    public partial class frmProviderDebtDialog : DevExpress.XtraEditors.XtraForm
    {
        BLL.OrderPayBLL orderPayBll = new BLL.OrderPayBLL();
        List<string> listBill = new List<string>();
        decimal amount = 0;
        public frmProviderDebtDialog(string providerID,string providerName,List<string> _listBill,decimal _amount)
        {
            InitializeComponent();
            listBill = _listBill;
            amount = _amount;
            groupControl1.Text = string.Format("欠款人：{0}", providerName);
            this._lblCopeAmount.Text = amount.ToString("f2") + "￥";
        }

        private void btnPayment_Click(object sender, EventArgs e)
        {
            decimal actualAmount = Convert.ToDecimal(this._ActualAmount.Text.Trim());
            if (string.IsNullOrEmpty(this._ActualAmount.Text.Trim()))
            {
                MsgBox.ShowWarning("请输入要付款的金额！");
                return;
            }
            if (actualAmount < amount)
            {
                MsgBox.ShowWarning("支付的金额低于销售单的最低销售金额！");
                return;
            }
            bool flag=orderPayBll.BatchHandleDebt(listBill);
            if (flag)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                MsgBox.ShowWarning("批量支付销售欠款出错！");
            }
        }
    }
}